package io.openkunlun.javadsl.serialization;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.cbor.databind.CBORMapper;

public class JacksonCborSerializer extends JacksonSerializer {

    private static final ObjectMapper MAPPER;

    static {
        MAPPER = new CBORMapper();
        MAPPER.configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true);
        MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        MAPPER.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
        MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    }

    /**
     *
     */
    public JacksonCborSerializer() {
        super(MAPPER);
    }

    /**
     * @param mapper
     */
    public JacksonCborSerializer(CBORMapper mapper) {
        super(mapper);
    }
}
